﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LogLib;
using ComLib.ConfigService;

namespace MainForm
{
    public class LanguageOption : IniConfigBase
    {
        private string _languageCode = "zh-CN";
        public string LanguageCode
        {
            get { return _languageCode; }
            set { _languageCode = value; }
        }

        public override bool Save()
        {
            base.Save();
            SaveField("Code", _languageCode);         
            return true;
        }

        public override bool Load()
        {
            base.Load();
            try
            {
                _languageCode = LoadStringValue("Code");              
            }
            catch (Exception ex)
            {
                ErrorMessage = string.Format("配置文件{0}加载错误:\n\t{1}", ConfigFilePath, ex.Message);
                Log.WriteException(ex.ToString());
                return false;
            }
            return true;
        }
  
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder("语言选项:");
            builder.Append("[语言代码]: " + _languageCode);          
            return builder.ToString();
        }
    }
}
